<?php

/**
 * This is the model class for table "{{app_profiles}}".
 *
 * The followings are the available columns in table '{{app_profiles}}':
 * @property integer $app_id
 * @property string $store_id
 * @property string $store_url
 * @property string $store_appname
 * @property string $description
 * @property string $whatsnew
 * @property double $score_sound
 * @property double $score_graphic
 * @property double $score_control
 * @property double $score_gameplay
 * @property double $score_cost
 */
class AppProfiles extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AppProfiles the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{app_profiles}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('app_id, store_id, store_url, store_appname, description, whatsnew', 'required'),
			array('app_id', 'numerical', 'integerOnly'=>true),
			array('score_sound, score_graphic, score_control, score_gameplay, score_cost', 'numerical'),
			array('store_id, store_appname', 'length', 'max'=>60),
			array('store_url', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('app_id, store_id, store_url, store_appname, description, whatsnew, score_sound, score_graphic, score_control, score_gameplay, score_cost', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'app_id' => 'App',
			'store_id' => 'Store',
			'store_url' => 'Store Url',
			'store_appname' => 'Store Appname',
			'description' => 'Description',
			'whatsnew' => 'Whatsnew',
			'score_sound' => 'Score Sound',
			'score_graphic' => 'Score Graphic',
			'score_control' => 'Score Control',
			'score_gameplay' => 'Score Gameplay',
			'score_cost' => 'Score Cost',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('app_id',$this->app_id);
		$criteria->compare('store_id',$this->store_id,true);
		$criteria->compare('store_url',$this->store_url,true);
		$criteria->compare('store_appname',$this->store_appname,true);
		$criteria->compare('description',$this->description,true);
		$criteria->compare('whatsnew',$this->whatsnew,true);
		$criteria->compare('score_sound',$this->score_sound);
		$criteria->compare('score_graphic',$this->score_graphic);
		$criteria->compare('score_control',$this->score_control);
		$criteria->compare('score_gameplay',$this->score_gameplay);
		$criteria->compare('score_cost',$this->score_cost);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}